// @ts-nocheck
import type { AppRouteRecordRaw, AppRouteModule } from "/@/router/types"
import { LAYOUT } from "/@/router/constant"
import { WELCOME_ROUTE, PAGE_NOT_FOUND_ROUTE, REDIRECT_ROUTE, ACCOUNT_PAGE } from "/@/router/routes/basic"
import { mainOutRoutes } from "/@/router/routes/mainOut"

import { PageEnum } from "/@/enums/pageEnum"
import { t } from "/@/hooks/web/useI18n"

const modules = import.meta.glob("./modules/**/*.ts", { eager: true })

const routeModuleList: AppRouteModule[] = []

// 加入到路由集合中
Object.keys(modules).forEach((key) => {
  const mod = (modules as Recordable)[key].default || {}
  const modList = Array.isArray(mod) ? [...mod] : [mod]
  routeModuleList.push(...modList)
})

export const asyncRoutes = [PAGE_NOT_FOUND_ROUTE, WELCOME_ROUTE, ...routeModuleList]

export const RootRoute: AppRouteRecordRaw = {
  id: "Root",
  path: "/",
  name: "Root",
  redirect: PageEnum.BASE_HOME,
  meta: {
    title: "Root",
  },
}

// Basic routing without permission
export const basicRoutes = [
  RootRoute,
  REDIRECT_ROUTE,
  ACCOUNT_PAGE,
  // PAGE_NOT_FOUND_ROUTE,
  ...mainOutRoutes,
]
